import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class RadioDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => RadioDemoState();
}

class RadioDemoState extends State<RadioDemo> {
  int sex = 1;

  int status = 1;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Radio',
          style: TextStyle(fontSize: 20, color: Colors.white),
        ),
        centerTitle: true,
      ),
      body: Padding(
        padding: EdgeInsets.all(16.0),
        child: Column(
          children: <Widget>[
            Row(
              children: <Widget>[
                Text('男'),
                Radio(
                    value: 1,
                    groupValue: this.sex,
                    onChanged: (value) {
                      setState(() {
                        sex = value as int;
                      });
                    }),
                Text('女'),
                Radio(
                    value: 2,
                    groupValue: this.sex,
                    onChanged: (value) {
                      setState(() {
                        sex = value as int;
                      });
                    }),
                Text('未知'),
                Radio(
                    value: 3,
                    groupValue: this.sex,
                    onChanged: (value) {
                      setState(() {
                        sex = value as int;
                      });
                    }),
              ],
            ),
            Row(
              children: <Widget>[
                // 组合选择项1
                // RadioListTile(
                //   value: 1,
                //   groupValue: this.status,
                //   onChanged: (value) {
                //     setState(() {
                //       this.status = value as int;
                //     });
                //   },
                //   title: Text("标题"),
                //   subtitle: Text("这是二级标题"),
                //   secondary: Icon(Icons.help),
                //   selected: this.status == 1,
                // ),

                // 组合选择项2
                // RadioListTile(
                //   value: 2,
                //   groupValue: this.status,
                //   onChanged: (value) {
                //     setState(() {
                //       this.status = value as int;
                //     });
                //   },
                //   title: Text("标题"),
                //   subtitle: Text("这是二级标题"),
                //   secondary: Image.network(
                //       'https://www.itying.com/images/flutter/1.png'),
                //   selected: this.status == 2,
                // ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
